local skel = fk.CreateSkill{
  name = "kqf__shenzhi",
}

Fk:loadTranslationTable{
  ["kqf__shenzhi"] = "神智",
  [":kqf__shenzhi"] = "准备阶段，你可以选择一名其他角色，视为你对其或其对你使用一张【移花接木】。",

  ["#kqf__shenzhi_choose"] = "神智：你可以选择一名其他角色，视为你对其或其对你使用一张【移花接木】",
  ["#kqf__shenzhi_choose1"] = "视为你对 %src 使用一张【移花接木】",
  ["#kqf__shenzhi_choose2"] = "视为 %src 对你使用一张【移花接木】",

  ["$kqf__shenzhi1"] = "望夫君，莫忘初心。",
  ["$kqf__shenzhi2"] = "子罕不受美玉，夫君可效仿前贤。",
}

skel:addEffect(fk.EventPhaseStart, {
  can_trigger = function(self, event, target, player, data)
    return target == player and player:hasSkill(skel.name) and player.phase == Player.Start
  end,
  on_cost = function(self, event, target, player, data)
    local room = player.room
    local to = room:askToChoosePlayers(player, {
      min_num = 1,
      max_num = 1,
      targets = room:getOtherPlayers(player, false),
      skill_name = skel.name, 
      prompt = "#kqf__shenzhi_choose",
      cancelable = true,
    })
    if #to > 0 then
      event:setCostData(self, {tos = to})
      return true
    end
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    local to = event:getCostData(self).tos[1]
    local choices = {"#kqf__shenzhi_choose1:" .. to.id, "#kqf__shenzhi_choose2:" .. to.id}
    local choice = room:askToChoice(player, {
      choices = choices,
      skill_name = skel.name,
    })
    if choice:startsWith("#kqf__shenzhi_choose1") then
      room:useVirtualCard("graft_and_transplant", nil, player, to, skel.name, true)
    else
      room:useVirtualCard("graft_and_transplant", nil, to, player, skel.name, true)
    end
  end,
})

return skel